import { App, createApp } from 'vue'
import VueApp from './App.vue'
import store from './store'
import { setupRouter } from './router'
import 'normalize.css'
import '@/style/index.scss'

function autoloadGlobalComponent(app: App) {
	const components = import.meta.globEager('@/components/global/**/*.vue')
	Object.entries(components).forEach(([filePath, component]) => {
		const componentName = filePath.replace(/.+global\/|\.vue/gi, '')
		app.component(componentName, component.default)
	})
}
;(async function main() {
	const app = createApp(VueApp)
	autoloadGlobalComponent(app)
	app.use(store)
	await setupRouter(app)
	app.mount('#app')
})()
